
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>购物车</title>
	</head>
	<body>
		<input type="text" id="Input" value="1" />
		<button type="button" id="jia">增加</button>
		<button type="button" id="jian">减少</button>
		<script>
			let max=10;
			let min=1;
			let Input = document.getElementById("Input");
			let jia = document.getElementById("jia");
			let jian = document.getElementById("jian");
		function doClickJia(){
			let v=Input.value;
			v=Number(v)+1;
			v = Math.min(v,max);
			Input.value=v;
		}
		function doClickJian(){
			let v=Input.value;
			v=Number(v)-1;
			v = Math.max(v,min);
			Input.value=v;
		}
		jia.addEventListener("click",doClickJia);
		jian.addEventListener("click",doClickJian);
		</script>
	</body>
</html>
